//
// Created by 邹迪凯 on 2021/7/20.
//

#include "util.h"
#include <cmath>

void testGenerateRandomPrime() {
    auto primes = generatePrimeList(10000);
    auto selected = randomSelect(primes, 10);
    for (const auto &item : *selected) {
        cout << item << " ";
    }
}

void testGenerateRandom() {
    srand(1);
    cout << rand() << endl;
    srand(2);
    cout << rand() << endl;
}

void testGenerateRandomId() {
    auto ids = generateRandomIds(400, 5, 03434);
    set<string> idSet;
    for (const auto &item : *ids) {
        idSet.insert(item);
    }
    cout << idSet.size() << endl;
    delete ids;
}

void testGetdistance() {
    double geo1[]{51.50056789326627, -0.12388767407988448};
    double geo2[]{51.50738662243948, -0.07581517018983762};
    cout << earthDistance(geo1[0], geo1[1], geo2[0], geo2[1]) << endl;
}

void testMillerConversionValidation() {
    double geo1[]{1.3596797371060807, 103.91104927354226};
    double geo2[]{1.37711800407082, 103.89846556981004};
    double distance = earthDistance(geo1[0], geo1[1], geo2[0], geo2[1]);
    double *millerGeo1 = millierConversion(geo1[0], geo1[1]);
    double *millerGeo2 = millierConversion(geo2[0], geo2[1]);
    double millerDistance = sqrt((millerGeo1[0] - millerGeo2[0]) * (millerGeo1[0] - millerGeo2[0]) +
                                 (millerGeo1[1] - millerGeo2[1]) * (millerGeo1[1] - millerGeo2[1]));
    cout << distance << endl;
    cout << millerDistance << endl;
}

void testGenerateLaplaceNoise(int seed) {
    srand(5);
    cout << laplaceNoise(1) << endl;
}

void testGenerateLaplaceNoise() {
    for (int i = 0; i < 10; i++) {
        cout << laplaceNoise(1) << endl;
    }
}

void testDoubleIntegrationOverLaplaceDist() {
    cout << integrateOverDoubleLaplace(0.1, 2, 5) << endl;
}

void testAes() {
    string key = "01234567890123456789012345678901";
    string clear("This is the clear text.");
    string cipher = encrypt(clear, key);
    string decrypted = decrypt(cipher, key);
    cout << decrypted << endl;
}

void testGetNanoSecondsUsingMacosAPI() {
    cout << now() << endl;
    cout << now() << endl;
    cout << now() << endl;
}